package com.pgytesting.secondhandcar.service.impl;

import com.pgytesting.secondhandcar.dao.LoanInformationDao;
import com.pgytesting.secondhandcar.model.LoanInformation;
import com.pgytesting.secondhandcar.service.LoanInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 贷款信息(LoanInformation)表服务实现类
 *
 * @author makejava
 * @since 2019-08-12 18:55:58
 */
@Service("loanInformationService")
public class LoanInformationServiceImpl implements LoanInformationService {
    @Resource
    private LoanInformationDao loanInformationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public LoanInformation queryById(String id) {
        return this.loanInformationDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<LoanInformation> queryAllByLimit(int offset, int limit) {
        return this.loanInformationDao.queryAllByLimit(offset, limit);
    }
    
    /**
     * 条件查询多条数据
     *
     * @param loanInformation 实例对象
     * @return 对象列表
     */
    @Override
    public List<LoanInformation> queryAll(LoanInformation loanInformation) {
        return this.loanInformationDao.queryAll(loanInformation);
    }

    /**
     * 新增数据
     *
     * @param loanInformation 实例对象
     * @return 实例对象
     */
    @Override
    public LoanInformation insert(LoanInformation loanInformation) {
        this.loanInformationDao.insert(loanInformation);
        return loanInformation;
    }

    /**
     * 修改数据
     *
     * @param loanInformation 实例对象
     * @return 实例对象
     */
    @Override
    public LoanInformation update(LoanInformation loanInformation) {
        this.loanInformationDao.update(loanInformation);
        return this.queryById(loanInformation.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.loanInformationDao.deleteById(id) > 0;
    }
}